﻿using eProcurement.BLL;
using eProcurement.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace eProcurement.members
{
    public partial class Settings : System.Web.UI.Page
    {
        Manager manager = new Manager();

        protected void Page_Load( object sender, EventArgs e )
        {
            if ( !IsPostBack )
            {
                AppUser user = manager.GetAppUser( Context.User.Identity.Name );
                txtUsername.InnerText = user.Username;
            }
        }

        protected void btnSave_Click( object sender, EventArgs e )
        {
            bool isformgood = true;
            AppUser user = manager.GetAppUser( Context.User.Identity.Name );

            lblPasswordMatchError.Visible = false;
            errpwdlength.Visible = false;
            lblOldPwdError.Visible = false;

            if ( user.Password != txtOldPassword.Value )
            {
                isformgood = false;
                lblOldPwdError.Visible = true;
            }

            if ( txtPassword.Value.Trim() == string.Empty || txtCPassword.Value.Trim() == string.Empty || txtPassword.Value != txtCPassword.Value )
            {
                isformgood = false;
                lblPasswordMatchError.Visible = true;
            }

            if ( txtPassword.Value.Count() < 6 )
            {
                isformgood = false;
                errpwdlength.Visible = true;
            }

            if ( isformgood )
            {
                
            }
        }
    }
}